package com.gxa.controller.ly.systemManagement;

import com.github.pagehelper.PageInfo;
import com.gxa.common.R;
import com.gxa.entity.SysMenuManagement;
import com.gxa.entity.SysStatusManagement;

import io.swagger.annotations.*;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@Api(value = "状态管理",tags = "状态管理接口API")
@Controller
@RequiresRoles(value = {"超级管理员","院长"},logical = Logical.OR)
@RequestMapping("/systemManagement/statusManagement")
public class StatusManagementController {

    /**
     * 查找所有状态管理接口
     * @param currentPage 当前页
     * @param pageSize 每页条数
     * @return JSON
     */
    @RequestMapping(value = "/findStatusList",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "查找所有状态管理接口",notes = "查找所有状态",httpMethod = "GET", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage", value = "当前页", paramType = "query", dataType = "String", required = true),
            @ApiImplicitParam(name = "pageSize", value = "页数", paramType = "query", dataType = "String", required = true),
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=400,message="参数错误"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R findStatusList(Integer currentPage,Integer pageSize) {

        R r = new R<>();
        SysStatusManagement sysStatusManagement = new SysStatusManagement();
        sysStatusManagement.setName("一般");
        sysStatusManagement.setListName("Address_list");
        sysStatusManagement.setValue(1);
        sysStatusManagement.setDisplay("显示");

        SysStatusManagement sysStatusManagement1 = new SysStatusManagement();
        sysStatusManagement1.setName("重要");
        sysStatusManagement1.setListName("Address_list");
        sysStatusManagement1.setValue(2);
        sysStatusManagement1.setDisplay("显示");

        List<SysStatusManagement> list = new ArrayList<>();
        list.add(sysStatusManagement);
        list.add(sysStatusManagement1);

        PageInfo<SysStatusManagement> pageInfo = new PageInfo<>(list);

        r.setCode(200);
        r.setMsg("success");
        r.setData(pageInfo);
        return r;
    }

    /**
     * 添加状态接口
     * @param sysStatusManagement 状态对象
     * @return 影响行数
     */
    @RequestMapping(value = "/addStatus",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "添加状态接口",notes = "添加状态",httpMethod = "POST", response = R.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=400,message="参数错误"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R addStatus(@RequestBody @ApiParam(name = "sysStatusManagement",value = "状态对象",required = true) SysStatusManagement sysStatusManagement) {
        R r = new R<>();
        if (sysStatusManagement != null) {
            return R.ok();
        }else {
            r.setCode(500);
            r.setMsg("添加失败");
        }
        return r;
    }

    /**
     * 删除菜单
     * @param id 菜单id
     * @return 影响行数或失败
     */
    @RequestMapping(value = "/delStatus",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "删除菜单接口",notes = "删除菜单",httpMethod = "POST", response = R.class)
    @ApiImplicitParam(name = "id", value = "菜单id", paramType = "query", dataType = "String", required = true)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=400,message="参数错误"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R delStatus(@RequestParam("id") Integer id) {
        R r = new R<>();
        if (id != null && id >=0) {
            return R.ok();
        }
        return r;
    }

    /**
     * 更新菜单接口
     * @param sysMenuManagement 需要修改的对象
     * @return 返回是否成功
     */
    @RequestMapping(value = "/updateMenu",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "更新菜单接口",notes = "更新菜单",httpMethod = "POST", response = String.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=400,message="参数错误"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R updateMenu(@RequestBody  @ApiParam(name = "sysMenuManagement",value = "菜单对象",required = true) SysMenuManagement sysMenuManagement) {
        R r = new R<>();
        if (sysMenuManagement != null) {
            return R.ok();
        }else {
            r.setCode(400);
            r.setMsg("添加失败");
        }
        return r;
    }
}
